<%@page import="com.sdry.model.llm.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>工位：切割</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/assets/ztree/css/zTreeStyle/zTreeStyle.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/css/w5.css">
	
	<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
	<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
	<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
	<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.all.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.exedit.js"></script>
	<script src="${pageContext.request.contextPath }/js/jyy/w5.js" charset="utf-8"></script>
	<script type="text/javascript">
	var format = "";
	
	//年月日+星期
	function load(){
		format = '${format}';
		var d=new Date(format);
		var day=d.getDate();
		var month=d.getMonth() + 1;
		var year=d.getFullYear();
		var weekday=new Array(7);
		weekday[0]="星期日";
		weekday[1]="星期一";
		weekday[2]="星期二";
		weekday[3]="星期三";
		weekday[4]="星期四";
		weekday[5]="星期五";
		weekday[6]="星期六";
		var b = d.toLocaleTimeString();
		document.getElementById('myTime').innerHTML = year + "年" + month + "月" + day+"日"+"&nbsp;<br>"+weekday[d.getDay()]+b;
	}
	//时分秒
	function mytime(){
		var d=new Date(format);
		var day=d.getDate();
		d.setSeconds(d.getSeconds()+1);
		format = d;
		var month=d.getMonth() + 1;
		var year=d.getFullYear();
		var weekday=new Array(7);
		weekday[0]="星期日";
		weekday[1]="星期一";
		weekday[2]="星期二";
		weekday[3]="星期三";
		weekday[4]="星期四";
		weekday[5]="星期五";
		weekday[6]="星期六";
		var b = d.toLocaleTimeString();
		document.getElementById('myTime').innerHTML = year + "年" + month + "月" + day+"日"+"&nbsp;<br>"+weekday[d.getDay()]+b;
	}
	setInterval(function() {mytime()},1000);
	</script>
</head>

<%
	User people = (User) request.getSession().getAttribute("currentUser");
    String name = null;
    if(people != null){
      name = people.getUserName();
    }
%>
<script type="text/html" id="rowToolbar">
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="back">带回</a>
</script>
	
<body>
   <table style="width: 99.8%; text-align: center; margin: 0px;" border="1px solid #000">
   		<tr>
   			<td rowspan="2" width="30%"><img alt="" src="${pageContext.request.contextPath }/img/logo.png" width="60%"></td>
   			<td rowspan="2" width="30%" style="background-color: #4472C4"><p class="font1">切割工位</p></td>
   			<td colspan="2" width="20%"><p class="font2" style="background-color: #4472C4; color: #ffffff">操作人</p></td>
   			<td rowspan="2" colspan="2" width="20%" style="background-color: #4472C4;"><a id="myTime"  class="font2"></a><a id="time1" class="font2"></a></td>
   		</tr>
   		<tr>
   			<td colspan="2"  class="font2" style="background-color: #4472C4; color: #ffffff" id="people"><%=name%></td>
   		</tr>
   		<tr>
   			<td  class="font31">排产单号</td>
   			<td  class="font31">当前产品</td>
   			<td colspan="4"  class="font31">膜管扫码</td>
   		</tr>
   		<tr>
   			<td  class="font3" id="planTime"></td>
   			<td  class="font3" id="product"></td>
   			<td colspan="4"  class="font3">
   				<input id="g1" placeholder="扫码输入框" style="width: 99%;border:1px #FFFFFF solid;text-align: center;">
   			</td>
   		</tr>
   		<tr>
   			<td  class="font31" >计划数量(支)</td>
   			<td  class="font31" >完成数量(支)</td>
   			<td colspan="4"  class="font31">A/B面硬度（HD）</td>
   		</tr>
   		<tr>
   			<td  class="font3" id="planNum"></td>
   			<td  class="font3" id="actualNum"></td>
   			<td  class="font3" style="width: 10%;">A</td>
   			<td  class="font3">
   				<input id="cremark1" style="border:1px #FFFFFF solid;text-align: center;">
   			</td>
   			<td  class="font3" style="width: 10%;">B</td>
   			<td  class="font3">
   				<input id="cremark2" style="border:1px #FFFFFF solid;text-align: center;">
   			</td>
   		</tr>
   		<tr>
   			<td></td>
   			<td   class="font31">当前年生产量(支)</td>
   			<td rowspan="5" colspan="4">
   				<table style="width: 99.8%; text-align: center; margin: 0px;" border="1px solid #000">
   					<tr>
   						<td colspan="2" class="font11" style="background-color: #4472C4;border-width: 8px; border-color: #ffffff" id="over">切割完成</td>
   					</tr>
   					<tr>
   						<td  class="font11" style="background-color: #4472C4;border-width: 8px; border-color: #ffffff" id="repair">设备报修</td>
   						<td  class="font11" style="background-color: #4472C4;border-width: 8px; border-color: #ffffff" id="bad">配件报检</td>
   					</tr>
   					<tr>
			   			<td class="font11" style="background-color: #4472C4;border-width: 8px; border-color: #ffffff" id="producCheck">产品报检</td>
			   			<td class="font11" style="background-color: #FFC000;border-width: 8px; border-color: #ffffff" color: #000000" onclick="agv()">AGV拉动</td>
   					</tr>
   					<tr>
   						<td  class="font11" style="background-color: #4472C4;border-width: 8px; border-color: #ffffff" id="technics">工艺卡</td>
   						<td  class="font11" style="background-color: #4472C4;border-width: 8px; border-color: #ffffff" id="job">作业管理</td>
   					</tr>
   					<tr>
   						<td colspan="2" class="font11" style="background-color: #676767;border-width: 8px; border-color: #ffffff;height: 60px;" id="back">注销</td>
   					</tr>
   				</table>
   			</td>
   		</tr>
   		<tr>
   			<td></td>
   			<td class="font3" id="yearNum"></td>
   		</tr>
   		<tr>
   			<td rowspan="2" colspan="2" style="padding: 0px;">
   				<table style="width: 100%; padding: 0px;margin: 0px;" id="table2">
   					<tr>
   						<th width="6%">序号</th>
   						<th width="15%">待切割  台车编码</th>
   						<th width="9%">组件数量</th>
   						<th>组件详细信息</th>
   					</tr>
   					<tr class="evenrowcolor">
   						<td>1</td>
   						<td id="c1"></td>
   						<td id="z1"></td>
   						<td>
   							<span id="s1"></span>
   							<span id="m1" class="tdtip">
   						 	</span>
   						</td>
   					</tr>
   					<tr class="oddrowcolor">
   						<td>2</td>
   						<td id="c2"></td>
   						<td id="z2"></td>
   						<td>
   							<span id="s2"></span>
   							<span id="m2" class="tdtip">
   						 	</span>
   						</td>
   					</tr>
   					<tr class="evenrowcolor">
   						<td>3</td>
   						<td id="c3"></td>
   						<td id="z3"></td>
   						<td>
   							<span id="s3"></span>
   							<span id="m3" class="tdtip">
   						 	</span>
   						</td>
   					</tr>
   					<tr class="oddrowcolor">
   						<td>4</td>
   						<td id="c4"></td>
   						<td id="z4"></td>
   						<td>
   							<span id="s4"></span>
   							<span id="m4" class="tdtip">
   						 	</span>
   						</td>
   					</tr>
   					<tr class="evenrowcolor">
   						<td>5</td>
   						<td id="c5"></td>
   						<td id="z5"></td>
   						<td>
   							<span id="s5"></span>
   							<span id="m5" class="tdtip">
   						 	</span>
   						</td>
   					</tr>
   				</table>
   			</td>
   		</tr>
   		<tr>
   		</tr>
   		<tr>
   			<td colspan="2" align="center">
   				<table style="width: 70%; text-align: center;" id="table3">
   					<tr>
   						<td style="width: 30%;border-width: 2px; color:#ffffff; font-size:24px; border-style: solid;border-color: #ffffff;background-color: #4472C4;line-height: 40px;">台车总数</td>
   						<td style="width: 20%;border-width: 2px; color:#ffffff; font-size:24px; border-style: solid;border-color: #ffffff;background-color: #4472C4;line-height: 40px;" id="tc"></td>
   						<td style="width: 30%;border-width: 2px; color:#ffffff; font-size:24px; border-style: solid;border-color: #ffffff;background-color: #4472C4;line-height: 40px;">组件总数</td>
   						<td style="width: 20%;border-width: 2px; color:#ffffff; font-size:24px; border-style: solid;border-color: #ffffff;background-color: #4472C4;line-height: 40px;" id="zc"></td>
   					</tr>
   				</table>
   			</td>
   		</tr>
   </table>
   
    <div id="peiDivID" hidden="hidden">
   
	   	<div class="demoTable" style="padding:10px 0 0 15px">
			<label class="layui-form-label">配件名称</label>
		    <div class="layui-inline">
		    	<input class="layui-input" name="searchName" id="searchName" placeholder="" style="display: inline; width: 80%">
		    </div>
		    <button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload" id="serch"><i class="layui-icon layui-icon-search">  搜索</i></button>
		</div>
		<table class="layui-hide" id="peiList" lay-filter="peiList"></table>
	</div>
   
   
    <div id="ngDivID" hidden="hidden">
	<form class="layui-form layui-card-body" id="formID" action="${pageContext.request.contextPath}/ng/insert.do">
	  	<input type="hidden" name="istation" value="切割">
	  	<div class="layui-form-item">
			<label class="layui-form-label">条码</label>
			<input class="layui-input" lay-verify="type" type="text" name="icode" id="icode" style="width:200px;">
		</div>
   		<div class="layui-form-item">
   			<div class="layui-inline">
				<label class="layui-form-label">配件名称</label>
				 <div class="layui-input-inline">
					<input class="layui-input" type="text" name="iname" id="iname" lay-verify="iname" style="width:200px;" onclick="pei()">
				</div>
			</div>
			<div class="layui-inline">
				<font style="color:red; font-size: 24px;">*</font>
		    </div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">配件规格</label>
			<div class="layui-input-block">
 				<input class="layui-input"  lay-verify="type" type="text" name="istandard" id="istandard" style="width:200px;">
 			</div>
		</div>
		<div class="layui-form-item"><label class="layui-form-label">配件批次号</label><input class="layui-input" lay-verify="type" type="text" name="ibatch" id="ibatch" style="width:200px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">配件数量</label><input class="layui-input" lay-verify="type" type="text" name="inum" id="inum" style="width:200px;"></div>
  		<div class="layui-form-item">
  			<label class="layui-form-label">异常描述</label>
  			<div class="layui-input-inline" style="width:200px;">
                <input type="text" name="idescription" id="idescription" class="layui-input" style="position:absolute;z-index:2;width:80%;" lay-verify="idescription" onkeyup="search()" autocomplete="off">
		      	<select type="text" id="hc_select"  lay-filter="hc_select" autocomplete="off" class="layui-select" lay-search>
		      	</select>
  			</div>
  			<div class="layui-inline">
				<font style="color:red; font-size: 24px;">*</font>
		    </div>
  		</div>
  		
  		 <div class="layui-form-item">
		    <label class="layui-form-label">是否推送</label>
		    <div class="layui-input-block">
		      <input type="checkbox" name="remark01" lay-skin="switch" lay-text="ON|OFF">
		    </div>
		  </div>
  		
  		<button class="layui-btn layui-btn-blue" lay-submit lay-filter="subform" id="save" style="margin-left:120px; margin-bottom: 20px">提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" id="cz" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>
	</form>
</div>
   
</body>

<script type="text/javascript">
var index;
function pei() {
	
	$("#searchName").val("");
	$("#serch").click();
	
	index = layer.open({
		type: 1 					//Page层类型
  		,area: ['750px', '600px'] 	//宽  高
  		,title: '选择配件'
  		,shade: 0.6 				//遮罩透明度
  		,maxmin: true 				//允许全屏最小化
  		,anim: 1 					//0-6的动画形式，-1不开启
  		,content: $("#peiDivID")
  		,end: function(){
  			$("#peiDivID").hide();
  		} 
	});
}
</script>
<script type="text/javascript">
$(function(){
    var index;
    /* $("#add").click(function(){ */
    $("body").on("click", "#add", function() {
        //console.log($(this).parents('tr').get(0));
        var rowId = $(this).parents('tr').attr("id");
        //alert(rowId);
        var tbody = document.getElementById("tbody");
        index = tbody.rows.length + 1;
        var tab = document.getElementById('myTable');
        //指定行号
        var rowNumNext = document.getElementById(rowId).rowIndex + 1;
        //在指定行下插入一行
        var tr = tab.insertRow(rowNumNext);
        //给tr设置动态Id和样式
        tr.id = "tr" + index;
        tr.style = "text-align: center";
        //在行下插入列内容
        var cell0 = tr.insertCell(0);
        var cell1 = tr.insertCell(1);
        var cell2 = tr.insertCell(2);
        var cell3 = tr.insertCell(3);
        var cell4 = tr.insertCell(4);

        cell0.innerHTML = '<td><input class="layui-input" id="changeDeviceName" name="changeDeviceName" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell1.innerHTML = '<td><input class="layui-input" id="deviceVersion" name="deviceVersion" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell2.innerHTML = '<td><input class="layui-input" id="deviceCount" name="deviceCount" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell3.innerHTML = '<td><input class="layui-input" id="deviceUnit" name="deviceUnit" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell4.innerHTML = '<td><i class="layui-icon layui-icon-add-1" id="add" style="font-size: 15px; color: #1E9FFF;"></i><br><i class="layui-icon layui-icon-close" id="recover" style="font-size: 15px; color: #1E9FFF; font-weight: bold;"></i></td>';
    });

    $("body").on("click", "#recover", function() {
        var rowId = $(this).parents('tr').attr("id");
        $("#"+rowId).remove();
    })
});
</script>
<script>
layui.use(['table','layer','upload','form','laydate'], function(){
	  var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
	  var table = layui.table;
	  var layer = layui.layer;
	  var laydate = layui.laydate;
	  var form = layui.form; 
	  
	  
	  
	  
	  form.on('select(hc_select)', function (data) {   //选择移交单位 赋值给input框
          $("#idescription").val(data.value);
          $("#hc_select").next().find("dl").css({ "display": "none" });
          form.render();
      });

      window.search = function () {
          var value = $("#idescription").val();
          $("#hc_select").val(value);
          form.render();
          $("#hc_select").next().find("dl").css({ "display": "block" });
          var dl = $("#hc_select").next().find("dl").children();
          var j = -1;
          for (var i = 0; i < dl.length; i++) {
              if (dl[i].innerHTML.indexOf(value) <= -1) {
                  dl[i].style.display = "none";
                  j++;
              }
              if (j == dl.length-1) {
                  $("#hc_select").next().find("dl").css({ "display": "none" });
              }
          }
          
      }
	  
	  
	  var $ = layui.jquery, active = {
		reload:function () {
			var searchName = $("#searchName").val();
			table.reload('contenttable',{
				method:'get',
				where:{"paname":searchName},
				page:{
					curr:1  //重新从第一页开始
				}
			});
		}
	  }
	  
	  $('.layui-btn').on('click', function(){
	      var type = $(this).data('type');
	      active[type] ? active[type].call(this) : '';
	  });
	  
	  table.render({
		    elem: '#peiList'
		    ,url:'${pageContext.request.contextPath }/partMana/listPagePart.do'
		    ,title: '配件列表'
		    ,id :'contenttable'
		    ,limits:[10,20,30]
		    ,cols: [[
				      {field:'paname', title:'配件名称',width:200},
				      {field:'panum', title:'配件编号' ,width:150},
				      {field:'pamodel', title:'配件规格',width:200},
				      {field:'paremark1', title:'计量单位',width:100},
				      //{field:'paremark2', title:'包装规格',width:100},
				      {fixed:'right', title:'操作', toolbar: '#rowToolbar', width:80}
				    ]],
		    page: true,
		});
	  
	  table.on('tool(peiList)', function(obj){
			var data = obj.data;
			console.log(obj)
			if(obj.event === 'back'){
				
			    $("#iname").val(obj.data.paname); 
			    $("#istandard").val(obj.data.pamodel); 
			    var id = obj.data.paid;
			    $.ajax({
			    	type:'post',
			    	data: {"id":id},
			    	url:'/solid/selectPcByPaid.do',
			    	success:function(data){
			    		$("#ibatch").val(data); 
			    	}
			    });
			    if($("#iname").val() != null ) {
			    	layer.close(index); 
			    }
			    
			}
		});

	
	  $.ajax({
	        type: "post",
	        url: "${pageContext.request.contextPath }/json/options.json",
	        dataType: 'JSON',
	        success: function (data) {
	              //设置下拉列表中的值的属性
	       		 $("#hc_select").append('<option value="">请选择</option>'); 
	              for ( var i = 0; i < data.length; i++) {
	            	  //增加下拉列表。
	            	  $("#hc_select").append("<option>"+data[i].name+"</option>");
	            	  form.render('select');
	              }
	        }
	  	});
	  
		/**
	      * 新增表单校验
	      */
	     form.verify({
	         //value：表单的值item：表单的DOM对象
	         deviceName: function(value, item){
	             if(value == ''){
	                 return '设备名称不能为空';
	             }
	         },
	         deviceNo: function(value, item){
	             if(value == ''){
	                 return '设备编号不能为空';
	             }
	         },
	         repairDept: function(value, item){
	             if(value == ''){
	                 return '报修部门不能为空';
	             }
	         },
	         iname: function(value, item){
	             if(value == ''){
	                 return '配件名称不能为空';
	             }
	         },
	         idescription: function(value, item){
	             if(value == ''){
	                 return '异常描述不能为空';
	             }
	         },
	     });
	  
	//监听行工具事件
	table.on('tool(tableList)', function(obj){
		var data = obj.data;
		var cremark = obj.data.cremark;
		if(obj.event === 'select'){
	   	layer.open({
			  type: 1 					//Page层类型
			  ,area: ['550px', '450px'] //宽  高
			  ,title: '编辑'
			  ,shade: 0.6 				//遮罩透明度
			  ,maxmin: true 			//允许全屏最小化
			  ,anim: 1 					//0-6的动画形式，-1不开启
			  ,content: '<table class="layui-hide" id="tableList2" lay-filter="tableList2"></table>'
			,success: function(){
				layui.use(['table'], function(){
	                var table = layui.table;
	                table.render({
	                    elem: '#tableList2'
	                    ,url:'${pageContext.request.contextPath }/solid/selectDetail.do?cremark='+cremark
	                    ,limits:[5]
	                    ,title: '组件列表'
	                    ,cols: [[
	                        {field:'stube', title:'组件条码'}
	                        ,{field:'cremark1', title:'绑定时间'}
	                    ]]
	                    ,page: true
	                });
	            });
			}
		 });
		} 
	 });
	  
  //选择文本框
  $("#g1").select();
  
  //切割完成
  $('#over').click(function(){   
	  var ctube=$.trim($("#g1").val());
	  var cremark1=$.trim($("#cremark1").val());
	  var cremark2=$.trim($("#cremark2").val());
	   
	  var reg = /^\d+(?=\.{0,1}\d+$|$)/
	  if(reg.test(cremark1) && reg.test(cremark2)) {
		  
		  if(parseInt(cremark1) > 10) {
			  toastr.warning("请输入0-10的数字！");
			  return
		  }
		  if(parseInt(cremark2) > 10) {
			  toastr.warning("请输入0-10的数字！");
			  return
		  }
		   
		  if(ctube == "" || ctube == undefined || ctube == null) {
			  toastr.warning("请扫描条码！");
			   return;
	 		}else {
 			 $.ajax({
 		    	type:'post',
 		    	url:'${pageContext.request.contextPath }/cut/edit.do',
 		    	data: {"ctube":ctube,"cremark1":cremark1,"cremark2":cremark2},
 		    	success:function(data){
 		    		if(data>0){
 		    			toastr.success("切割完成！");
						$("#g1").val("");
						$("#cremark1").val("");
						$("#cremark2").val("");
						selectActualNum();
						selectYearNum();
						selectList2();
						//查询固化区的台车总数
						 selectTc();
						//查询固化区的组件总数
						 selectZc();
						$("#g1").select();
 		    		}else if(data == -1) {
 		    			 selectList2();
 		    			toastr.warning("该膜管已切割完成！");
 		    			$("#g1").select();
 		    		}else{
 		    			toastr.error("对不起,该产品还没有开始切割,不能结束!！");
 		    		}
 		    	}
 		    })
 		 }  
	   }else {
		   toastr.warning("A/B面硬度请输入正数！");
	   }
  });
  
  //设备报修
 $('#repair').click(function(){   
	 layer.open({
         type: 1 					//Page层类型
         ,area: ['50%', '83%'] 	//宽  高
         ,title: '设备报修'
         ,shade: 0.6 				//遮罩透明度
         ,maxmin: true 				//允许全屏最小化
         ,anim: 1 					//0-6的动画形式，-1不开启
         //,content: $("#addFormID")
         ,content: '<form class="layui-form" id="addFormID">'+
         '<table>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label" style="margin-top: 20px;width:150px;" >设备编号</label></td>'+
             '<td>'+
                 '<div>'+
                     '<div style="width: 200px; margin-left: 0px; float: left; margin-top: 20px">'+
                         '<select class="layui-select" id="deviceNo" name="deviceNo" lay-filter="displayInfo" lay-verify="deviceNo">'+
                             '<option value="">请选择</option>'+
                         '</select>'+
                     '</div>'+
                     '<div style="margin-top: 29px; float: left">'+
                         '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
                     '</div>'+
                 '</div>'+
             '</td>'+ 					
             '<td><label class="layui-form-label left-label" style="margin-top: 20px;width:150px;">故障设备名称</label></td>'+
             '<td><input type="text" id="deviceName" name="deviceName" lay-verify="deviceName" class="layui-input" style="width:200px; margin-top: 20px; display: inline;">' +
                 '<div class="layui-inline" style="margin-top: 4px;">'+
                     '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
                 '</div>'+
             '</td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label" style="width:150px;">报修部门/车间</label></td>'+
             '<td>'+
                 '<div>'+
                     '<div style="width: 200px; margin-left: 0px; float: left">'+
                         '<select class="layui-select" id="repairDept" name="repairDept" lay-verify="repairDept">'+
                             '<option value="">请选择</option>'+
                         '</select>'+
                     '</div>'+
                     '<div style="margin-top: 9px; float: left">'+
                         '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
                     '</div>'+
                 '</div>'+
             '</td>'+
             '<td><label class="layui-form-label left-label" style="width:150px;">报修人</label></td>'+
             '<td><input type="text" name="repairMan" id="repairMan" value="<%= name%>" class="layui-input" style="width:200px"></td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label"  style="width:150px;">报修时间</label></td>'+
             '<td><input type="text" name="repairTime" id="repairTime"  class="layui-input" style="width:200px"></td>'+
             '<td></td>'+
             '<td></td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td><label class="layui-form-label left-label" style="width:150px;">故障现象描述</label></td>'+
             '<td colspan="3"><textarea class="layui-textarea" id="errorDescribe" name="errorDescribe" style="width: 540px; height: 150px;"></textarea></td>'+
         '</tr>'+
         '<tr style="height:10px"></tr>'+
         '<tr>'+
             '<td colspan="2">' +
                 '<label class="layui-form-label" style="width:150px;">审批人</label>' +
                 '<input readonly class="layui-input" lay-verify="approvalPeople" placeholder="请选择审批人" name="approvalPeople" id="approvalPeople" type="text" style="width:100px; display:inline; margin-left: 19px">' +
                 '<i style="font-size:15px;" id="refresh" class="layui-icon layui-icon-refresh"></i>' +
                 '<ul id="treeConfig" class="ztree" style="margin-left: 120px;"></ul>'+
             '</td>'+
             '<td colspan="2">' +
                 '<label class="layui-form-label" style="width:150px;">抄送人</label>' +
                 '<input readonly class="layui-input" lay-verify="ccPeople" placeholder="请选择三个抄送人" name ="ccPeople" id="ccPeople" type="text" style="width:200px; display:inline">' +
                 '<i style="font-size: 15px;" id="dCopyMenRefresh" class="layui-icon layui-icon-refresh"></i>'+
                 '<ul id="dCopyMenConfig" class="ztree" style="margin-left: 100px;"></ul>'+
             '</td>'+
         '</tr>'+
         '<tr style="height:20px"></tr>'+
         '<tr align="center">'+
             '<td colspan="2"><button class="layui-btn layui-btn-blue" id="subBtn" lay-submit lay-filter="addForm" style="margin-left:160px; margin-bottom: 20px">提交</button>&emsp;&emsp;'+
             '<td colspan="2"><button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>'+
         '<tr>'+
     '</table>'+
 '</form>'
     
			,success: function(){
			 
			 var people = $("#people").text();
				$("#repairMan").val(people);
			 
			 //报修时间
			 laydate.render({
			     elem: '#repairTime'
			 });
				//维修起始时间
			 laydate.render({
			     elem: '#fixStartTime'
			 });
			 //维修结束时间
			 laydate.render({
			     elem: '#fixEndTime'
			 });
			 //验收日期
			 laydate.render({
			     elem: '#acceptTime'
			 });
				//下拉查找所有设备
			 $.ajax({
			          type: 'POST',
			          url: '${pageContext.request.contextPath}/device/queryAllDeviceList.do',
			          dataType: 'json',
			          async: false,
			          success: function (data){
			              for (var i = 0; i < data.length; i++) {
			                  $("#deviceNo").append("<option value='"+ data[i].deviceNo +"'>"+ data[i].deviceNo +"</option>");
			              }
			          }
			      });
				//下拉框查找所有部门
				$.ajax({
			        type: 'POST',
			        url: '${pageContext.request.contextPath}/device/queryAllDeptList.do',
			        dataType: 'json',
			        async: false,
			        success: function (data){
			            for (var i = 0; i < data.length; i++) {
			                $("#repairDept").append("<option value='"+ data[i].name +"'>"+ data[i].name +"</option>");
			            }
			        }
			    });
				
				
				 $("#refresh").click(function(){
			            $("#approvalPeople").val("");
			        })
			        $("#dCopyMenRefresh").click(function(){
			            $("#ccPeople").val("");
			        })
			
			        var setting = {
			            isSimpleData : true,             //数据是否采用简单 Array 格式，默认false
			            treeNodeKey : "id",              //在isSimpleData格式下，当前节点id属性
			            treeNodeParentKey : "pId",       //在isSimpleData格式下，当前节点的父节点id属性
			            showLine : true,                 //是否显示节点间的连线
			            checkable : true,                //每个节点上是否显示 CheckBox
			            data: {
			                simpleData: {
			                    enable: true,
			                    idKey: "id",
			                    pIdKey: "pId",
			                    rootPid: "0"
			                }
			            },
			            callback: {
			                onDblClick: onDblClick,
			            }
			        };
			
			        var dCopyMenSetting = {
			            isSimpleData : true,              //数据是否采用简单 Array 格式，默认false
			            treeNodeKey : "id",               //在isSimpleData格式下，当前节点id属性
			            treeNodeParentKey : "pId",        //在isSimpleData格式下，当前节点的父节点id属性
			            showLine : false,                 //是否显示节点间的连线
			            data: {
			                simpleData: {
			                    enable: true,
			                    idKey: "id",
			                    pIdKey: "pId",
			                    rootPid: "0"
			                }
			            },
			            callback: {
			                onDblClick: dCopyMenOnDblClick,
			            }
			        };
			
			        function onDblClick(e,treeId,treeNode) {
			
			            selectedNode = treeNode;
			            var name = treeNode.name;
			            var id = treeNode.id;
			            var type = treeNode.type;
			            if(type!="-1"){
			                var dApprover1 = $("#approvalPeople").val();
			                var dApprovers = dApprover1.split(",");
			                for(var i=0;i<dApprovers.length;i++){
			                    if(name==dApprovers[i]){
			                        toastrStyle();
			                        toastr.warning("选择了重复的审批人！")
			                        name = "";
			                    }
			                }
			                var dApprover2;
			                if(dApprover1 == "" && name != ""){
			                    dApprover2 = $("#approvalPeople").val((dApprover1+','+name).substring(1));
			                }else if(name != ""){
			                    dApprover2 = $("#approvalPeople").val(dApprover1+','+name);
			                }
			                var dApprover3 =  $("#approvalPeople").val();
			                var dApprovers3 = dApprover3.split(",");
			                var dApprovers3Length = dApprovers3.length;
			                if(dApprovers3Length>1){
			                    toastr.warning("最多选择1个审批人");
			                    $("#approvalPeople").val(dApprover1);
			                }
			            }else{
			                toastrStyle();
			                toastr.warning("请选择审批人！")
			            }
			        }
			
			        function dCopyMenOnDblClick(e,treeId,treeNode) {
			            dCopyMenSelectedNode = treeNode;
			            var name = treeNode.name;
			            var id = treeNode.id;
			            var type = treeNode.type;
			
			            var dCopyMen = $("#ccPeople").val();
			            var dCopyMen = dCopyMen.split(",");
			            for(var i=0;i<dCopyMen.length;i++){
			                if(name==dCopyMen[i]){
			                    toastrStyle();
			                    toastr.warning("选择了重复的抄送人！")
			                    name = "";
			                }
			            }
			            if(dCopyMen == "" && name != ""){
			                dCopyMen = $("#ccPeople").val((dCopyMen+','+name).substring(1));
			            }else if(name != ""){
			                dCopyMen = $("#ccPeople").val(dCopyMen+','+name);
			            }
			        }
			
			        $.ajax({
			            type:'get',
			            url:'${pageContext.request.contextPath }/disposeRejects/getZtreeJson.do',
			            dataType:'json',
			            success: function(data){
			                var	zNodes = data.rows;
			                $(document).ready(function() {
			                    $.fn.zTree.init($("#treeConfig"), setting, zNodes);
			                });
			            },
			            error: function(){
			                toastrStyle();
			                toastr.error("请求失败");
			            }
			        });
			
			        $.ajax({
			            type:'get',
			            url:'${pageContext.request.contextPath }/disposeRejects/getZtreeJson.do',
			            dataType:'json',
			            success: function(data){
			                var	dCopyMenzNodes = data.rows;
			                $(document).ready(function() {
			                    $.fn.zTree.init($("#dCopyMenConfig"), dCopyMenSetting, dCopyMenzNodes);
			                });
			            },
			            error: function(){
			                toastrStyle();
			                toastr.error("请求失败");
			            }
			        });
				
			 //初始化radio、select等元素
			 form.render();
			}
		});
	})
   //注销
  $('#back').click(function(){   
	  window.location.href="${pageContext.request.contextPath }/logout.do";
   });
  
//工艺卡
 $('#technics').click(function(){  
	window.location.href="${pageContext.request.contextPath }/jumpPage/craftDetails.do";
  })
  
  //作业管理
 $('#job').click(function(){   
	 //传值：工位
	window.location.href="${pageContext.request.contextPath }/jumpPage/workManage.do?positionName=切割";
});
  
   //产品报检
  $('#producCheck').click(function(){   
	  window.location.href="${pageContext.request.contextPath }/cut/enterProductInspectionPage.do";
   })
   
    //配件报检
    /*  $('.mySelect').find('input').removeAttr("readonly"); */
 $('#bad').click(function(){   
	 layer.open({
	   type: 1 					//Page层类型
  		,area: ['500px', '650px'] 	//宽  高
  		,title: '配件报检'
  		,shade: 0.6 				//遮罩透明度
  		,maxmin: true 				//允许全屏最小化
  		,anim: 1 					//0-6的动画形式，-1不开启
  		,content: $("#ngDivID")
  		,end: function(){
  			$("#ngDivID").hide();
  			$("#g1").select();
  		}
   		,success: function(layero, index){
   			$("#cz").click();
   			
   			form.render();
   			
   			$("#icode").focus(); 
   			
	       	 this.enterEsc = function(event){
		          if(event.keyCode === 13){
		            return false; //阻止系统默认回车事件
		          }
	        }; 
	        $(document).on('keydown', this.enterEsc);	//监听键盘事件，关闭层
	    }
   	});
  })
  
    /**
      * 设备报修
      */
     form.on('submit(addForm)', function (data) {
    	 $("#subBtn").attr("disabled",true);
         $.ajax({
             url : '${pageContext.request.contextPath}/breakdown/addDeviceBreakdown.do',
             data: $("#addFormID").serialize(),
             cache : false,
             type : "post",
         }).done(
             function(res) {
                 if (res > 0) {
                     toastr.success('报修成功！');
                     layer.closeAll();
                 }
             }
         ).fail(
             function(res) {
                 toastr.error('报修失败！');
                 layer.closeAll();
             }
         )
         return false;
     });
  
	//查找带回
  form.on('select(displayInfo)', function(data){
  	$.ajax({
          type: 'POST',
          url: '${pageContext.request.contextPath}/device/queryDeviceInfoByNo.do',
          data: {deviceNo:$('#deviceNo').val()},
          success: function (data){
          	var device = eval('(' +data+ ')');
          	$('#deviceName').val(device.deviceName);
          }
      });
  });
  
  form.on('submit(subform)', function (data) {
	  
	  $("#save").attr("disabled",true);
	  
	  var datas=data.field;
   	  var action=data.form.action;
   	  $.ajax({
   		  url:action,
   		  data:datas,
   		  type:"POST",
   		  dataType:"json",
   		  success:function(result){
   			 if(result > 0) {
   				toastr.success("报检成功！");
   				$("#reset").click();
   				layer.closeAll();
   			 }else {
   				 toastr.warning("报检失败！");
   				 return false;
   			 }
   		  },
   	  });
   	  
   	  return false;
	  });
  
  toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
  toastr.options.timeOut = '2000'; //自动关闭时间
});
</script>
</html>